package com.hbmcc.heshenghuo.functions.glide

import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.view.View
import android.widget.ImageView
import androidx.annotation.DrawableRes
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation

/**
 * Copyright (c) 2020
 * author: whs
 * created on: 2020/9/17 16:10
 * description:
 */
interface ImgOptionsInterface {
    /**
     * 占位图片
     */
    fun placeholder(@DrawableRes placeholderResId: Int?): ImgOptionsInterface

    /**
     * 加载失败图片
     */
    fun error(@DrawableRes errorResId: Int?): ImgOptionsInterface

    /**
     * 图片剪切类型
     */
    fun centerCrop(): ImgOptionsInterface
    fun fitCenter(): ImgOptionsInterface
    fun centerInside(): ImgOptionsInterface

    /**
     * 设置圆角
     */
    fun transform(transformation: BitmapTransformation?): ImgOptionsInterface

    fun dontTransform(): ImgOptionsInterface

    fun dontAnimate(): ImgOptionsInterface

    /**
     * 设置缓存策略
     */
    fun diskCacheStrategy(strategy: DiskCacheStrategy): ImgOptionsInterface

    /**
     * 设置图片宽高
     */
    fun override(width: Int, height: Int): ImgOptionsInterface

    /**
     * 控件自适应指定宽度
     */
    fun autoFit(width: Int): ImgOptionsInterface

    /**
     * 填充图片
     */
    fun into(imageView: ImageView?)

    /**
     * 填充背景
     */
    fun into(view: View?)

    /**
     * 返回bitmap
     */
    fun get(width: Int, height: Int): Bitmap?

    /**
     * 获取bitmap
     */
    fun intoBitmap(bitmapInterface: BitmapInterface)

    interface BitmapInterface {
        fun onSuccess(bitmap: Bitmap)
        fun onError(errorDrawable: Drawable?)
    }

}